package hu.monitor.agent.remoting;

import hu.monitor.remoting.transport.Client;
import hu.monitor.remoting.transport.ClientPool;
import hu.monitor.remoting.transport.Marshaller;
import hu.monitor.remoting.transport.socket.SocketClient;

import java.io.IOException;
import java.net.SocketAddress;

public class SimpleClientPool implements ClientPool {
	private final Marshaller marshaller;
	private final SocketAddress address;

	public SimpleClientPool(final Marshaller marshaller, final SocketAddress address) {
		this.marshaller = marshaller;
		this.address = address;
	}

	@Override
	public Client getClient() {
		return new SocketClient(this.marshaller, this.address);
	}

	@Override
	public void releaseClient(final Client client) throws IOException {
		client.close();
	}

}
